﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
using WorkflowDesigner.Properties;
using System.Drawing.Drawing2D;

namespace WorkflowDesigner
{
    public class AuditNode : FlowNode
    {
        private Label lblText = new Label();

        public AuditNode(FlowDesinger desinger)
            : base(desinger)
        {
            this.Text = "审批节点";
            //显示图片
            var img = new PictureBox();
            img.Image = Resources.AuditUser;
            img.Size = new Size(40, 40);
            img.SizeMode = PictureBoxSizeMode.StretchImage;
            img.Location = new Point(this.Left + (this.Width - 40) / 2, this.Top + 5);
            this.Controls.Add(img);
            img.Enabled = false;
            //显示文字
            lblText.Text = this.Text;
            lblText.AutoSize = false;
            lblText.Location = new Point(this.Left + 4, this.Top + this.Height - 20);
            lblText.Size = new Size(this.Width - 8, 16);
            lblText.AutoEllipsis = true;
            lblText.ForeColor = Color.Green;
            lblText.TextAlign = ContentAlignment.MiddleCenter;
            this.Controls.Add(lblText);
            //TODO:最好能有3D效果
            this.BackColor = SystemColors.Control;

            this.DoubleClick += new EventHandler(AuditNode_DoubleClick);

            this.TextChanged += new EventHandler(AuditNode_TextChanged);
        }

        void AuditNode_TextChanged(object sender, EventArgs e)
        {
            this.lblText.Text = this.Text;
        }

        void AuditNode_DoubleClick(object sender, EventArgs e)
        {
            fmAuditNodeProperty.Show(this);
        }

    }
}
